#include "Node.h"
#include "../SGD Wrappers/CSGD_Direct3D.h"
#include "Elemental.h"
#include "../SGD Wrappers/CSGD_TextureManager.h"
#include "Player.h"
CNode::CNode(void)
{
	TypeofObj = Obj_Waypoint;
	m_pOwner = nullptr;

	timerCountdown = 0;
	soulTimer = 2;
}


CNode::~CNode(void)
{
}

void CNode::Render( void )
{
	RECT temp;
	temp.bottom = (LONG)(CEntity::GetPosY()+2);
	temp.top = (LONG)(CEntity::GetPosY()-2);
	temp.left = (LONG)(CEntity::GetPosX()-2);
	temp.right = (LONG)(CEntity::GetPosX()+2);

	CSGD_TextureManager::GetInstance()->Draw(GetImageID(), (int)(GetPosX()), (int)(GetPosY()),
		2.0f,2.0f);
}

void CNode::Update( float fElapsedTime )
{
	if( m_pOwner != nullptr )
	{
		timerCountdown = timerCountdown + fElapsedTime;
	if( timerCountdown > soulTimer )
	{
		m_pOwner->PoolGeneration(soulType);
		timerCountdown = 0;
	}
	}
}


bool CNode::CheckCollision( IEntity * pOther )
{
	if( CEntity::CheckCollision(pOther) != true )
	{
		return false;
	}
	switch( pOther->GetType() )
		case Obj_Elemental:
	{
		if( dynamic_cast<CElemental*>(pOther)->GetTeam() == 1 )
		{
			SetImageID(10);
		}
		else
		{
			SetImageID(15);
		}
		m_pOwner = dynamic_cast<CElemental*>(pOther)->GetOwner();
		return true;
	}
	return false;
}